<?php

/**
 * This is the model class for table "fundus".
 *
 * The followings are the available columns in table 'fundus':
 * @property integer $id
 * @property string $medis_od
 * @property string $media_os
 * @property string $disc_od
 * @property string $disk_os
 * @property string $cup_od
 * @property string $cup_os
 * @property string $vessels_od
 * @property string $vessels_os
 * @property string $periphery_od
 * @property string $preiprhery_os
 * @property string $macula_od
 * @property string $macula_os
 * @property integer $rx_id
 * @property integer $personalinfo_id
 *
 * The followings are the available model relations:
 * @property Rx $rx
 * @property PersonalInformation $personalinfo
 */
class Fundus extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Fundus the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'fundus';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rx_id, personalinfo_id', 'numerical', 'integerOnly'=>true),
			array('medis_od, media_os, disc_od, disk_os, cup_od, cup_os, vessels_od, vessels_os, periphery_od, preiprhery_os, macula_od, macula_os', 'length', 'max'=>5),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, medis_od, media_os, disc_od, disk_os, cup_od, cup_os, vessels_od, vessels_os, periphery_od, preiprhery_os, macula_od, macula_os, rx_id, personalinfo_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'rx' => array(self::BELONGS_TO, 'Rx', 'rx_id'),
			'personalinfo' => array(self::BELONGS_TO, 'PersonalInformation', 'personalinfo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'medis_od' => 'Medis Od',
			'media_os' => 'Media Os',
			'disc_od' => 'Disc Od',
			'disk_os' => 'Disk Os',
			'cup_od' => 'Cup Od',
			'cup_os' => 'Cup Os',
			'vessels_od' => 'Vessels Od',
			'vessels_os' => 'Vessels Os',
			'periphery_od' => 'Periphery Od',
			'preiprhery_os' => 'Preiprhery Os',
			'macula_od' => 'Macula Od',
			'macula_os' => 'Macula Os',
			'rx_id' => 'Rx',
			'personalinfo_id' => 'Personalinfo',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('medis_od',$this->medis_od,true);
		$criteria->compare('media_os',$this->media_os,true);
		$criteria->compare('disc_od',$this->disc_od,true);
		$criteria->compare('disk_os',$this->disk_os,true);
		$criteria->compare('cup_od',$this->cup_od,true);
		$criteria->compare('cup_os',$this->cup_os,true);
		$criteria->compare('vessels_od',$this->vessels_od,true);
		$criteria->compare('vessels_os',$this->vessels_os,true);
		$criteria->compare('periphery_od',$this->periphery_od,true);
		$criteria->compare('preiprhery_os',$this->preiprhery_os,true);
		$criteria->compare('macula_od',$this->macula_od,true);
		$criteria->compare('macula_os',$this->macula_os,true);
		$criteria->compare('rx_id',$this->rx_id);
		$criteria->compare('personalinfo_id',$this->personalinfo_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	public function getFName()
        {       
        return $this->personal_information['FullName']; 
        }
}